package com.sigmatrix.h5.service.db;

import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.sigmatrix.h5.config.TableUtils;
import com.sigmatrix.h5.entity.v2.CodeFleeCheckRecord;
import com.sigmatrix.h5.entity.v2.DisDealer;
import com.sigmatrix.h5.exception.MessageException;
import com.sigmatrix.h5.mapper.CodeFleeCheckRecordMapper;
import com.sigmatrix.h5.service.v2.CommonDBService;

@Service
public class CodeFleeCheckRecordDBService extends CommonDBService<CodeFleeCheckRecordMapper, CodeFleeCheckRecord> {

	public List<CodeFleeCheckRecord> findByIds(Integer[] ids, String eseCode) {
		return baseMapper.findByIds(ids, TableUtils.tablePrefixBy(eseCode));
	}
	
	public Integer insertAndReturnId(CodeFleeCheckRecord record) {
		return baseMapper.insertAndReturnId(record);
	}
	
	public CodeFleeCheckRecord findByCirIdAndQrcode(String circulationId,String qrcode,String eseCode) {
		CodeFleeCheckRecord record = new CodeFleeCheckRecord();
		record.setTablePrefix(TableUtils.tablePrefixBy(eseCode));
		record.setCirculationId(circulationId);
		record.setQrCode(qrcode);
		List<CodeFleeCheckRecord> selectList = selectList(new EntityWrapper<CodeFleeCheckRecord>(record));
		if(selectList!=null){
//			if(selectList.size()>1){
//				throw new MessageException("表CodeFleeCheckRecord.findByCirIdAndQrcode查询发生多条数据。circulationId:"+circulationId +"  qrcode: "+qrcode);
//			}
			if(!selectList.isEmpty()){
				return selectList.get(0);
			}
		}
		return null;
	}

}
